﻿Imports System.Net
Imports System.IO
Class MainWindow


    Private Sub MainWindow_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded

        Dim appURL As String = "http://login.yahoo.com/config/login"
        Dim strPostData As String = [String].Format("login={0}&password={1}", "myloginname", "mypassword")

        ' Setup the http request.
        Dim wrWebRequest As HttpWebRequest = TryCast(WebRequest.Create(appURL), HttpWebRequest)
        wrWebRequest.Method = "POST"
        wrWebRequest.ContentLength = strPostData.Length
        wrWebRequest.ContentType = "application/x-www-form-urlencoded"
        wrWebRequest.CookieContainer = New CookieContainer()

        ' Post to the login form.
        Dim swRequestWriter As New StreamWriter(wrWebRequest.GetRequestStream())
        swRequestWriter.Write(strPostData)
        swRequestWriter.Close()

        ' Get the response.
        Dim hwrWebResponse As HttpWebResponse = DirectCast(wrWebRequest.GetResponse(), HttpWebResponse)

        ' Have some cookies.
        Dim ccCookies As CookieCollection = hwrWebResponse.Cookies

        ' Read the response
        Dim srResponseReader As New StreamReader(hwrWebResponse.GetResponseStream())
        Dim strResponseData As String = srResponseReader.ReadToEnd()
        srResponseReader.Close()

        WebBrowser1.Navigate("https://exch.d-systeme.at/owa/")

    End Sub

    Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

    End Sub
End Class
